﻿/* **********************************************************************************
 *
 * Copyright (c) WickedFlame Projects. All rights reserved.
 *
 * This source code is subject to terms and conditions of the Microsoft Reciprocal License
 * for WickedFlame. A copy of the license can be found in the License.html file
 * at the root of this distribution. 
 * By using this source code in any fashion, you are agreeing to be bound by
 * the terms of the Microsoft Reciprocal License for WickedFlame.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * **********************************************************************************/
using System;
using System.Collections;

namespace Gencode.Controls.NavigationPane
{
	public class NavigationPaneEnumerator : IEnumerator
	{
		int index = -1;
        NavigationPaneCollection collection;

        public NavigationPaneEnumerator(NavigationPaneCollection collection)
		{
			this.collection = collection;
		}

		#region IEnumerator Members

		public object Current
		{
			get
			{
				if (index >= collection.Count)
					index = collection.Count - 1;
				return collection[index];
			}
		}

		public bool MoveNext()
		{
			index++;
			if (index < collection.Count)
				return true;
			else
			{
				index--;
				return false;
			}
		}

		public void Reset()
		{
			index = 0;
		}

		#endregion
	}
}
